{% extends "start.html" %}
{% block content %}
<div id="main">
  <div id="rightbar">
  <div id="reviewchoices">
     <h3><center>Filter Corrections</center></h3>
    <form action="" method="POST">
    <table>
    {{ reviewchoicesform.as_table }}
    <tr>
    <td></td>
    <td>
    <input type="submit" name="which_post" value="Filter" id="submit" />
        <div id="reviewchoices_errors" style="color: red;">
            {% if reviewchoicesform.errors %}
            <p>
                Please correct the error{{ reviewchoicesform.errors|pluralize }} below.
            </p>
            <ul>
            {% for field in reviewchoicesform %}
              {% if field.errors %}
                <li>{{ field.label }} <strong>{{ field.errors }}</strong></li>
               {% endif %}
            {% endfor %}
            </ul>
            {% endif %}
        </div>
    </td>
    </tr>
    </table>
    </form>
   </div>
  </div>
  <div id="corrections">
    <table class="wordlist">
    {% if corrections %}
      <thead>
        <tr>
        <th>Correction</th>
        <th>Corrector</th>
        <th>Approver</th>
        <th>Applier</th>
        <th>Status</th>
        </tr>
      </thead>
      <tbody>
      {% for correction in corrections.object_list %}
        <tr>
          <td>
              {% ifnotequal correction.get_operation_display "Update" %}<b>{% endifnotequal %}
               {{ correction.get_operation_display }} 
              {% ifnotequal correction.get_operation_display "Update" %}</b>{% endifnotequal %}
               {{ correction.wordid_from.get_textid }}-{{ correction.wordid_from.citation }}:
              {{ correction.wordid_from.KwicL }} 
              <br>
              {% ifnotequal correction.operation 2 %}<span style="background-color:yellow;">{% endifnotequal %}
              {{ correction.spelling_from }} ({{ correction.lemma_from }}, 
              {{ correction.pos_from }}){% ifnotequal correction.operation 2 %}</span>{% endifnotequal %}
              {% ifnotequal correction.operation 3 %}
              <span style="background-color:#50f733;">
              {% if correction.spelling_to %} 
                 <b>{{ correction.spelling_to }}</b> 
              {% else %}
                 {{ correction.spelling_from }} 
              {% endif %}
              {% if correction.lemma_to %}
                 (<b>{{ correction.lemma_to }}</b> 
              {% else %}
                 ({{ correction.lemma_from }}
              {% endif %},
              {%if correction.pos_to %}
                 <b>{{ correction.pos_to }}</b>) 
              {% else %}
                 {{ correction.pos_from }})
              {% endif %}
              </span>
              {% endifnotequal %}
              {{ correction.wordid_from.KwicR }}
              <br> {{ correction.annotation }}</td>
          <td>{{ correction.corrected_by }} <br> {{ correction.corrected_date }}</td>
          <td>{{ correction.status_by }} <br> {{ correction.status_date }}</td>
          <td>{{ correction.applied_by }} <br> {{ correction.applied_date }}</td>

          <td>
              {% if user.is_authenticated and 'annolexapp.can_review' in user.get_all_permissions %}

            <form action="" method="post" onsubmit="">
              <select id="select_status" 
                      name="which_post" 
                      onchange="this.form.submit();">
                  <option value="Status_Unapproved"{% ifequal correction.status 1 %} selected="1" {% endifequal %}>Unapproved</option>
                  <option value="Status_Approved"{% ifequal correction.status 2 %} selected="2" {% endifequal %}>Approved</option>
                  <option value="Status_Rejected"{% ifequal correction.status 3 %} selected="3" {% endifequal %}>Rejected</option>
                  <option value="Status_Held"{% ifequal correction.status 4 %} selected="4" {% endifequal %}>Held</option>
              </select>
              <input type="hidden" name="id" value="{{ correction.id }}" />
            </form>
          {% else %}
              {% ifequal correction.status 1 %} Unapproved {% endifequal %}
              {% ifequal correction.status 2 %} Approved {% endifequal %}
              {% ifequal correction.status 3 %} Rejected {% endifequal %}
              {% ifequal correction.status 4 %} Held {% endifequal %}
          {% endif %}
          </td>
        </tr>
    
      {% endfor %}

      </tbody>
    {% else %}
    <tr><td>There are currently no corrections to review.</td></tr>
    {% endif %}
    </td></tr>
    </table>
  </div> <!-- wordlist -->
<div id="pagination" class="pagination" align="right">
    <span class="step-links">
        {% if corrections.has_previous %}
            <a href="?page=1">First</a> &middot;
            <a href="?page={{ corrections.previous_page_number }}">Previous</a> &middot;
        {% endif %}

        <span class="current">
            Page {{ corrections.number }} of {{ corrections.paginator.num_pages }}
        </span>

        {% if corrections.has_next %}
            &middot; <a href="?page={{ corrections.next_page_number }}">Next</a>
            &middot;<a href="?page=last">Last</a>
        {% endif %}
    </span>
</div>
</div> <!-- main -->
{% endblock %}
